package letterbox;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

class Crossword {

     final ArrayList<Clue> acrossClues, downClues;
     final String title;
     final int size;

     Crossword(String title, int size, ArrayList<Clue> acrossClues, ArrayList<Clue> downClues){
	this.title = title;
        this.size = size;
	this.acrossClues = acrossClues;
        this.downClues = downClues;
    }


     public Set<Cell> getCells(){
         Set<Cell> cells = new HashSet<Cell>();
         for(int i = 0; true; i++){
             if(i < acrossClues.size()){
                 Clue c = acrossClues.get(i);
                 int x = c.x;
                 for(int j = 0; j < c.answer.length(); j++){
                     cells.add(new Cell(c.answer.charAt(j), x++, c.y));
                 }
             }
             if(i < downClues.size()){
                 Clue d = downClues.get(i);
                 int y = d.y;
                 for(int j = 0; j < d.answer.length(); j++){
                     cells.add(new Cell(d.answer.charAt(j), d.x, y++));
                 }
             }
             if(i >= acrossClues.size() && i >= downClues.size())
                 break;
         }
         return cells;
     }
}

class Clue {
     final int number, x,y;
     final String clue, answer;

     Clue(int number, int x, int y, String clue, String answer){
	this.number = number;
	this.x = x;
	this.y = y;
	this.clue = clue;
	this.answer = answer;
    }
}
